<?xml version="1.0" encoding="UTF-8"?>
<!--
To change this template, choose Tools | Templates
and open the template in the editor.
-->
<!DOCTYPE html>
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
                xmlns:h="http://java.sun.com/jsf/html"
                xmlns:ui="http://java.sun.com/jsf/facelets"
                xmlns:f="http://java.sun.com/jsf/core"
                xmlns:dt="http://java.sun.com/jsf/composite/components"
                xmlns:p="http://primefaces.org/ui"
                template="./template1.xhtml">
    
    <ui:define name="mainContent">
        <h2>Add/Drop/Trade</h2>
        <ul id="games">
                <li>
                        <h3 class="fancy">Players</h3>
                        <h:outputLabel value="Search for player: " />
                        <p:inputText value="#{addBean.searchPlayer}" id="search" />
                        <p:commandButton value="Search" actionListener="#{addBean.searchPlayer}" update="searchResult" />
                        <h:outputLabel value="#{addBean.error}" id="addError" /><br/>
                        <h:panelGrid id="searchResult" >
                            <ui:repeat value="#{addBean.searchResults}" var="result" >
                                <h:outputLabel value="#{result}" />
                                <p:commandLink value="Add " actionListener="#{teamBean.addPlayer}" update=":players,:addError" >
                                    <f:setPropertyActionListener target="#{teamBean.activePlayer}" value="#{result}" />
                                </p:commandLink>
                                <p:commandLink value="Drop " actionListener="#{teamBean.dropPlayer}" update=":players,:addError" >
                                    <f:setPropertyActionListener target="#{teamBean.activePlayer}" value="#{result}" />
                                </p:commandLink>
                                <p:commandLink value="Trade " actionListener="#{teamBean.tradePlayer}" update=":players,:addError" >
                                    <f:setPropertyActionListener target="#{teamBean.activePlayer}" value="#{result}" />
                                </p:commandLink>
                            </ui:repeat>
                        </h:panelGrid>
                </li>
        </ul>
    </ui:define>
    
    <ui:define name="secondaryContent">
        <h3>Players</h3>
        <h:panelGrid id="players">
            <ui:repeat value="#{teamBean.players}" var="player" >
                <p:commandLink value="#{player}" update=":search,:searchResult" >
                    <f:setPropertyActionListener target="#{addBean.searchPlayer}" value="#{player}" />
                </p:commandLink><br/>
            </ui:repeat>
        </h:panelGrid>
    </ui:define>
    
</ui:composition>
